#include "PlayerEntity.h"
#include "ItemEntity.h"

PlayerEntity::PlayerEntity()
{
    LivingEntity();
    hud = NULL;
    maxHp = 0;
}

void PlayerEntity::setHUD(HUD* h)
{
    hud = h;
}

int PlayerEntity::timeInvulnerable()
{
    return 60;
}

void PlayerEntity::takeHit(int d, Entity* e)
{
    LivingEntity::takeHit(d,e);
    hud->updateLife(hp, maxHp);
}

void PlayerEntity::heal(int i)
{
    LivingEntity::heal(i);
    hud->updateLife(hp, maxHp);
}

int PlayerEntity::getMaxHP()
{
    return maxHp;
}

void PlayerEntity::pickup(ItemEntity* item)
{
    if(item->useOnPickup())
    {
        item->onUse(this);
    }
    else
    {
        // For inventory items. Soon.
    }
    item->setRemove();
}

Entity* PlayerEntity::clone()
{
    return new PlayerEntity(*this);
}

LivingEntity* PlayerEntity::setMaxHP(int i)
{
    hp = maxHp = i;
    return this;
}
